package com.ynr.common.utils;

import java.io.Serializable;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.annotation.JsonIgnore;

public class BaseModel implements Serializable {

	private static final long serialVersionUID = 1L;

	private static final Logger logger = LoggerFactory
			.getLogger(BaseModel.class);
	
	public interface UpdateGroup{};
	
	public interface CreateGroup{};
	
	@JsonIgnore
	public long id;
	
	public String create_date;
	
	public String update_date;
	
	@JsonIgnore
	public Timestamp update_time;
	
	@JsonIgnore
	public Timestamp create_time;

	public BaseModel() {
		
	}
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getCreate_date() {
		return create_date;
	}

	public String getUpdate_date() {
		return update_date;
	}

	public Timestamp getUpdate_time() {
		return update_time;
	}

	public Timestamp getCreate_time() {
		return create_time;
	}
	
	public void setUpdate_time(Timestamp update_time) {
		this.update_time = update_time;
		try {
			DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	        this.update_date = sdf.format(update_time);
		} catch(Exception e) {
			this.update_date = "";
			logger.error("baseModel setUpdate_time exception:{}", e.toString());
		}
	}

	public void setCreate_time(Timestamp create_time) {
		this.create_time = create_time;
		try {
			DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	        this.create_date = sdf.format(create_time);
		} catch(Exception e) {
			this.create_date = "";
			logger.error("baseModel setCreate_time exception:{}", e.toString());
		}
	}

	@Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }
	
}
